<template>
  <div>
    <el-dialog title="选择活动优惠券" :visible.sync="formInline.show">
      <el-table :data="counpList">
        <el-table-column label="序号" width="50" align="center">
          <template slot-scope="scope">
            {{ scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column
          property="couponName"
          label="名称"
          width="300"
          align="center"
        ></el-table-column>
        <el-table-column
          property="createTime"
          label="时间"
          width="300"
          align="center"
        ></el-table-column>
        <el-table-column property="date" label="操作" width="55" align="center">
          <template slot-scope="scope">
            <div
              v-if="scope.row"
              @click="add(scope.row)"
              style="color: rgba(22, 155, 213, 1)"
              class="hands"
            >
              添加
            </div>
          </template>
        </el-table-column>
      </el-table>
      <pageCom
        :searchParams="searchParams"
        :total="total"
        @searchList="getInitData"
      ></pageCom>
      <div
        slot="footer"
        class="dialog-footer"
        style="display: flex; justify-content: center; align-items: center"
      >
        <el-button @click="formInline.show = false" type="primary"
          >关闭</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { couList } from '@/api/activeList/index.js'
export default {
  props: {
    formInline: {
      type: Object,
      default: function() {
        return {
          show: false,
          index: '',
          type: '',
          ind: ''
        }
      }
    },
    pages: {
      type: Object,
      default: function() {
        return {
          page: 1,
          size: 10
        }
      }
    }
  },
  data() {
    return {
      counpList: [],
      searchParams: {
        pageNum: 1,
        pageSize: 10
      },
      total: 10,
      gridData: []
    }
  },
  created() {},
  mounted() {
    this.getInitData()
  },
  methods: {
    getInitData() {
      let obj = {
        type: 'marketing',
        ...this.searchParams
      }
      couList(
        obj,
        (res) => {
          this.counpList = res.rows
          this.total = res.total
        },
        (err) => {}
      )
    },
    generlData() {
      this.$emit('generlData')
    },
    searchList() {},
    add(item) {
      let _this = this
      if (this.formInline.index !== '') {
        this.$emit(
          'backData',
          item,
          _this.formInline.index,
          _this.formInline.ind,
          _this.formInline.type
        )
        _this.formInline.show = false
      }
    }
  }
}
</script>

<style lang="less" scoped>
:deep(.el-dialog) {
  width: 40% !important;
}
.bor_one {
  border: 1px solid black;
}
.hands {
  cursor: pointer;
}
</style>
